﻿using Prism.Commands;
using Prism.Modularity;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Zhy.PrismModule.ViewModels
{
    public class MainWindowViewModel
    {
        /// <summary>
        /// 打开ViewA页面按钮
        /// </summary>
        public ICommand OpenCommand { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="regionManager">管理区域的对象注入</param>
        /// <param name="moduleManager">管理项目模块的对象注入</param>
        public MainWindowViewModel(
            IRegionManager regionManager,
            IModuleManager moduleManager)
        {
            OpenCommand = new DelegateCommand<string>(viewName => // 打开ViewA页面按钮
            {
                moduleManager.LoadModule("AAA"); // 使用时加载指定名称的项目模块
                regionManager.RequestNavigate("MainRegion", viewName); // 将ViewA页面显示到导航区域中
            });
        }
    }
}
